package com.luban.util;

import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.DateTimeZone;
import org.springframework.beans.factory.annotation.Autowired;

public class DateUtil {

    @Autowired
    private UtilProperties prop;

    //时区转换
    public String getLocalTime(){
        int zone = 8;
        if(prop.getLatitude() != null){
            zone = (int)(Math.round(prop.getLatitude() * DateTimeConstants.HOURS_PER_DAY)/360);
        }
        DateTimeZone dz = DateTimeZone.forOffsetHours(zone);
        return new DateTime(dz).toString(prop.getPattern());
    }

}
